import type { App } from 'vue';

import { ElLoading, ElScrollbar } from 'element-plus';

const plugins = [ElLoading];

const components = [ElScrollbar];

export const setupElementPlus = (app: App<Element>) => {
  plugins.forEach((plugin) => {
    app.use(plugin);
  });

  if (import.meta.env.VITE_USE_ALL_ELEMENT_PLUS_STYLE === 'true') {
    import('element-plus/dist/index.css');
    return;
  }

  components.forEach((component) => {
    app.component(component.name!, component);
  });
};
